/* =================================
   计算组件样式
   ================================= */

/* 页面容器 */
.page-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    padding: var(--space-xl);
}

/* 页面标题区域 */
.page-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
    color: white;
}

.page-title {
    font-size: var(--font-3xl);
    font-weight: 700;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    color: var(--primary-green);
}

.page-title i {
    font-size: 3rem;
    color: var(--accent-cyan);
}

.page-subtitle {
    font-size: var(--font-xl);
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

/* =================================
   模式选择器
   ================================= */
.mode-selector {
    margin-bottom: var(--space-2xl);
}

.mode-tabs {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    max-width: 800px;
    margin: 0 auto;
}

.mode-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xl);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all var(--duration-normal) ease;
    position: relative;
    overflow: hidden;
}

.mode-tab::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(76, 175, 80, 0.1), transparent);
    transition: left 0.5s ease;
}

.mode-tab:hover::before {
    left: 100%;
}

.mode-tab i {
    font-size: 2.5rem;
    color: var(--accent-cyan);
    margin-bottom: var(--space-sm);
}

.tab-text {
    font-size: var(--font-xl);
    font-weight: 600;
    color: white;
}

.tab-desc {
    font-size: var(--font-sm);
    opacity: 0.8;
}

.mode-tab:hover {
    transform: translateY(-5px);
    border-color: var(--primary-green);
    box-shadow: 0 10px 30px rgba(76, 175, 80, 0.2);
}

.mode-tab.active {
    background: rgba(76, 175, 80, 0.1);
    border-color: var(--primary-green);
    color: white;
    box-shadow: 0 0 30px rgba(76, 175, 80, 0.3);
}

.mode-tab.active i {
    color: var(--primary-green);
}

/* =================================
   计算区域布局
   ================================= */
.calc-section {
    display: none;
    animation: fadeInUp 0.6s ease-out;
}

.calc-section.active {
    display: block;
}

.calc-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-xl);
    max-width: 1600px;
    margin: 0 auto;
}

/* =================================
   面板通用样式
   ================================= */
.input-panel,
.process-panel,
.result-panel {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: 12px;
    box-shadow: var(--shadow-xl);
    height: fit-content;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-title {
    font-size: var(--font-xl);
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.panel-title i {
    color: var(--primary-green);
    font-size: var(--font-lg);
}

/* =================================
   参数输入区域
   ================================= */
.param-groups {
    margin-bottom: var(--space-xl);
}

.param-group {
    margin-bottom: var(--space-xl);
    background: rgba(29, 43, 64, 0.3);
    border-radius: var(--radius-lg);
    padding: 12px;
    border: 1px solid rgba(33, 150, 243, 0.2);
}

.group-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--accent-cyan);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.group-title i {
    color: var(--accent-orange);
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

.param-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.param-item.full-width {
    grid-column: 1 / -1;
}

.param-item label {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.param-item input,
.param-item select {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: white;
    font-size: var(--font-base);
    transition: all var(--duration-normal) ease;
}

.param-item input:focus,
.param-item select:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
    outline: none;
}

.param-unit {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.6);
    margin-left: var(--space-sm);
}

/* 重置按钮 */
.reset-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: var(--radius-md);
    color: var(--accent-orange);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: all var(--duration-normal) ease;
}

.reset-btn:hover {
    background: rgba(255, 152, 0, 0.2);
    transform: translateY(-1px);
}

/* =================================
   计算按钮
   ================================= */
.calc-actions {
    display: flex;
    gap: var(--space-md);
}

.calc-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    font-size: var(--font-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-normal) ease;
    border: none;
    position: relative;
    overflow: hidden;
}

.calc-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.6s ease;
}

.calc-btn:hover::before {
    width: 300px;
    height: 300px;
}

.calc-btn.primary {
    background: linear-gradient(135deg, var(--primary-green), #66BB6A);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.calc-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

.calc-btn.secondary {
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid rgba(33, 150, 243, 0.3);
    color: var(--accent-blue);
}

.calc-btn.secondary:hover {
    background: rgba(33, 150, 243, 0.2);
    transform: translateY(-2px);
}

/* =================================
   计算过程区域
   ================================= */
.process-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.status-text {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.8);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.ready {
    background: var(--primary-green);
}

.status-indicator.processing {
    background: var(--accent-orange);
}

.status-indicator.error {
    background: var(--text-error);
}

/* 计算步骤 */
.process-steps {
    margin-bottom: var(--space-xl);
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-lg);
    transition: all var(--duration-normal) ease;
    position: relative;
}

.step-item::before {
    content: '';
    position: absolute;
    left: 20px;
    top: 45px;
    width: 2px;
    height: calc(100% + 16px);
    background: rgba(255, 255, 255, 0.1);
}

.step-item:last-child::before {
    display: none;
}

.step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-lg);
    position: relative;
    z-index: 1;
}

.step-content {
    flex: 1;
}

.step-title {
    font-size: var(--font-base);
    font-weight: 600;
    color: white;
    margin-bottom: var(--space-xs);
}

.step-desc {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: var(--space-sm);
}

.step-time {
    font-size: var(--font-xs);
    color: var(--primary-green);
    font-weight: 600;
}

/* 步骤状态 */
.step-item.completed {
    background: rgba(76, 175, 80, 0.1);
}

.step-item.completed .step-icon {
    background: var(--primary-green);
    color: white;
}

.step-item.processing {
    background: rgba(255, 152, 0, 0.1);
}

.step-item.processing .step-icon {
    background: var(--accent-orange);
    color: white;
}

.step-item.pending .step-icon {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
}

/* 步骤进度条 */
.step-progress {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-orange), var(--accent-cyan));
    border-radius: var(--radius-sm);
    transition: width var(--duration-normal) ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

.progress-text {
    font-size: var(--font-xs);
    color: var(--accent-orange);
    font-weight: 600;
    min-width: 35px;
}

/* =================================
   计算日志
   ================================= */
.calc-log {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-lg);
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.log-title {
    font-size: var(--font-base);
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.log-title i {
    color: var(--primary-green);
}

.log-content {
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    font-size: var(--font-sm);
    line-height: 1.4;
}

.log-time {
    color: rgba(255, 255, 255, 0.5);
    min-width: 65px;
}

.log-level {
    font-weight: 600;
    min-width: 70px;
}

.log-entry.info .log-level {
    color: var(--accent-cyan);
}

.log-entry.success .log-level {
    color: var(--primary-green);
}

.log-entry.warning .log-level {
    color: var(--accent-orange);
}

.log-entry.error .log-level {
    color: var(--text-error);
}

.log-message {
    color: rgba(255, 255, 255, 0.8);
    flex: 1;
}

/* =================================
   结果展示区域
   ================================= */
.result-actions {
    display: flex;
    gap: var(--space-sm);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid rgba(33, 150, 243, 0.3);
    border-radius: var(--radius-md);
    color: var(--accent-blue);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: all var(--duration-normal) ease;
}

.action-btn:hover {
    background: rgba(33, 150, 243, 0.2);
    transform: translateY(-1px);
}

/* 关键指标卡片 */
.key-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.metric-card {
    background: rgba(29, 43, 64, 0.4);
    border-radius: var(--radius-lg);
    padding: 12px;
    text-align: center;
    transition: all var(--duration-normal) ease;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-green), var(--accent-cyan));
}

.metric-card.excellent::before {
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
}

.metric-card.good::before {
    background: linear-gradient(90deg, #2196F3, #42A5F5);
}

.metric-card.warning::before {
    background: linear-gradient(90deg, #FF9800, #FFB74D);
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.2);
}

.metric-icon {
    font-size: 2rem;
    color: var(--primary-green);
    margin-bottom: var(--space-sm);
}

.metric-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.metric-value .value {
    font-size: var(--font-2xl);
    font-weight: 700;
    color: white;
}

.metric-value .unit {
    font-size: var(--font-base);
    color: rgba(255, 255, 255, 0.7);
}

.metric-label {
    font-size: var(--font-sm);
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: var(--space-sm);
}

.metric-change {
    font-size: var(--font-xs);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

.metric-change.positive {
    color: var(--primary-green);
}

.metric-change.negative {
    color: var(--accent-orange);
}

/* =================================
   结果表格
   ================================= */
.result-table {
    margin-bottom: var(--space-xl);
}

.table-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.table-title i {
    color: var(--primary-green);
}

.optimization-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(29, 43, 64, 0.4);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.optimization-table th {
    background: rgba(29, 43, 64, 0.8);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--accent-cyan);
    border-bottom: 2px solid var(--primary-green);
    font-size: var(--font-sm);
}

.optimization-table td {
    padding: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--font-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.optimization-table tbody tr:hover {
    background: rgba(76, 175, 80, 0.08);
}

.number-cell {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.number-cell.good {
    color: var(--primary-green);
}

.number-cell.warning {
    color: var(--accent-orange);
}

.number-cell.excellent {
    color: var(--accent-cyan);
}

/* 状态徽章 */
.status-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 50px;
    text-align: center;
}

.status-badge.status-excellent {
    background: rgba(76, 175, 80, 0.2);
    color: var(--primary-green);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.status-badge.status-good {
    background: rgba(33, 150, 243, 0.2);
    color: var(--accent-blue);
    border: 1px solid rgba(33, 150, 243, 0.3);
}

/* =================================
   单点优化特殊样式
   ================================= */
/* 流向流量矩阵 */
.flow-matrix {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
}

.flow-direction {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 12px;
}

.flow-direction label {
    display: block;
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--accent-cyan);
    margin-bottom: var(--space-sm);
    text-align: center;
}

.flow-inputs {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.flow-inputs input {
    padding: var(--space-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: white;
    font-size: var(--font-sm);
    text-align: center;
}

/* 优化目标选择 */
.objective-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.objective-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-normal) ease;
}

.objective-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-green);
}

.objective-item input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    position: relative;
    transition: all var(--duration-normal) ease;
}

.objective-item input[type="radio"]:checked + .radio-custom {
    border-color: var(--primary-green);
}

.objective-item input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: var(--primary-green);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.objective-content strong {
    color: white;
    font-size: var(--font-base);
    display: block;
    margin-bottom: var(--space-xs);
}

.objective-content p {
    color: rgba(255, 255, 255, 0.7);
    font-size: var(--font-sm);
    margin: 0;
}

/* 单点结果指标 */
.single-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

/* 相位配时图表 */
.timing-title {
    font-size: var(--font-base);
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.timing-chart {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-lg);
    padding: 12px;
}

.phase-bar {
    display: flex;
    height: 60px;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.phase-segment {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: var(--font-sm);
    font-weight: 600;
    position: relative;
}

.phase-segment.phase-1 {
    background: linear-gradient(135deg, #4CAF50, #66BB6A);
}

.phase-segment.phase-2 {
    background: linear-gradient(135deg, #2196F3, #42A5F5);
}

.phase-segment.phase-3 {
    background: linear-gradient(135deg, #FF9800, #FFB74D);
}

.phase-segment.phase-4 {
    background: linear-gradient(135deg, #f44336, #ef5350);
}

.phase-label {
    font-size: var(--font-xs);
    opacity: 0.9;
}

.phase-time {
    font-size: var(--font-sm);
    font-weight: 700;
}

.timing-scale {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-xs);
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Courier New', monospace;
}

/* =================================
   动画效果
   ================================= */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* =================================
   响应式调整
   ================================= */
@media (max-width: 1400px) {
    .calc-layout {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-lg);
    }
    
    .process-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 1024px) {
    .calc-layout {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }
    
    .mode-tabs {
        flex-direction: column;
        max-width: 400px;
    }
    
    .param-grid {
        grid-template-columns: 1fr;
    }
    
    .key-metrics {
        grid-template-columns: 1fr;
    }
    
    .single-metrics {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: var(--space-lg);
    }
    
    .calc-actions {
        flex-direction: column;
    }
    
    .flow-matrix {
        grid-template-columns: 1fr;
    }
    
    .optimization-table {
        font-size: var(--font-xs);
    }
    
    .optimization-table th,
    .optimization-table td {
        padding: var(--space-sm);
    }
}
